//
//  QLViewController.m
//  Test
//
//  Created by Shrek on 15/5/12.
//  Copyright (c) 2015年 Personal. All rights reserved.
//

/** QLDEBUG Print */
#ifdef DEBUG
#define QLLog(FORMAT, ...) fprintf(stderr,"M:%s|L:%d :%s\n", __FUNCTION__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define QLLog(FORMAT, ...)
#endif

#import "QLViewController.h"

@interface QLViewController ()

@end

@implementation QLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    [self threadCreate3];
}

- (void)threadCreate3 {
    [self performSelectorInBackground:@selector(doit:) withObject:@"threadCreate3"];
}

- (void)threadCreate2 {
    [NSThread detachNewThreadSelector:@selector(doit:) toTarget:self withObject:@"threadCreate2"];
}

- (void)threadCreate1 {
    NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(doit:) object:@"threadCreate1"];
    [thread setThreadPriority:0.5];
    thread.name = @"线程A";
    [thread start];
}

- (void)doit:(NSString *)string { // 子线程调用
    QLLog(@"%@-%@", string, [NSThread currentThread]);
}

@end
